package com.core.dto;

import com.core.model.lxf.SocketUser;

import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-12-23
 * Time: 下午2:40
 * To change this template use File | Settings | File Templates.
 */
public class SocketUserDTO {

    private String sessionId;
    private String username;

    public SocketUserDTO() {
    }

    public SocketUserDTO(String sessionId, String username) {
        this.sessionId = sessionId;
        this.username = username;
    }

    public static SocketUserDTO toDTO(SocketUser socketUser) {
        return new SocketUserDTO(socketUser.session().getId(), socketUser.username());
    }

    public static List<SocketUserDTO> toDTOs(List<SocketUser> socketUsers) {
        List<SocketUserDTO> socketUserDTOs = new ArrayList<>();
        for (SocketUser s : socketUsers) {
            socketUserDTOs.add(toDTO(s));
        }
        return socketUserDTOs;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
